package jd;

public class Grant {
	public String grant_id;
	public String acronym;
	public String country;
	public String agency;
	boolean inited = false;
	
	void init() {
		if (inited == true)
			return;

		if (grant_id == null)
			grant_id = "";
		grant_id = grant_id.replaceAll("'", "''");

		if (acronym == null)
			acronym = "";
		acronym = acronym.replaceAll("'", "''");

		if (country == null)
			country = "";
		country = country.replaceAll("'", "''");

		if (agency == null)
			agency = "";
		agency = agency.replaceAll("'", "''");

		inited = true;
	}

	public String to_str() {
		String ret;

		init();

		ret = String.format("'%s', '%s', '%s', '%s'", 
			grant_id, acronym, country, agency);
		return ret;
	}

	public String to_cond() {
		String ret;

		init();

		ret = String.format("grant_id='%s' AND acronym='%s' AND " +
			"country='%s' AND agency='%s'",
			grant_id, acronym, country, agency);
		return ret;
	}
}


